import * as i18n from '@/utils';
let gType_list = [
	{ label: i18n.t('goods.groupM.normalGood'), value: 1 },
	{ label: i18n.t('goods.groupM.hotelGood'), value: 2 },
	{ label: i18n.t('goods.groupM.ticket'), value: 3 }
]
let positionList = [
	{
		push_type: 1,
		label: i18n.t('mock.advertisement'),
		value: 1,
		list: [
			{ label: i18n.t('mock.FullAd'), value: 1 },
			{ label: i18n.t('mock.HalfAd'), value: 2 }
		]
	},
	{
		push_type: 2,
		label: i18n.t('machine.custom.animation'),
		value: 2,
		list: [
			{ label: i18n.t('mock.GiftAnimation'), value: 1 },
			{ label: i18n.t('mock.shipmentAnim'), value: 2 },
			{ label: i18n.t('mock.pickupAnim'), value: 3 },
			// { label: i18n.t('mock.MachineAnim'), value: 4 },
			// { label: i18n.t('mock.MachinepickupAnim'), value: 5 },
			// { label: i18n.t('mock.SmallAnim'), value: 6 },
			{ label: i18n.t('mock.resultPpage'), value: 7 },
			{ label: i18n.t('mock.resultPpageof'), value: 8 },
			{ label: i18n.t('mock.resultPpagecode'), value: 9 }
		]
	},
	{
		push_type: 3,
		label: i18n.t('machine.custom.voice'),
		value: 3,
		list: [
			{ label: i18n.t('mock.homepage'), value: 1 },
			{ label: i18n.t('mock.payment'), value: 2 },
			{ label: i18n.t('mock.giftSound'), value: 3 },
			{ label: i18n.t('mock.pickupPrompt'), value: 4 },
			{ label: i18n.t('mock.NextPickup'), value: 5 },
			{ label: i18n.t('mock.completetran'), value: 6 },
			{ label: i18n.t('mock.Reminder'), value: 7 },
			{ label: i18n.t('mock.Remind'), value: 8 },
			{ label: i18n.t('mock.surprise'), value: 9 },
			{ label: i18n.t('mock.payAlipay'), value: 10 },
			{ label: i18n.t('mock.UnionPay'), value: 11 },
			{ label: i18n.t('mock.cardPay'), value: 12 },
			{ label: i18n.t('mock.WeChatPay'), value: 13 },
			{ label: i18n.t('mock.JDPay'), value: 14 },
			{ label: i18n.t('mock.HomeGreet'), value: 15 },
			{ label: i18n.t('mock.customers'), value: 16 },
			{ label: i18n.t('mock.POPPay'), value: 17 }
		]
	}
]
let noticeList = [
	{ label: i18n.t('mock.onlineNot'), value: 'online' },
	{ label: i18n.t('mock.offlineNot'), value: 'offline' },
	{ label: i18n.t('mock.FaultNot'), value: 'fault' },
	{ label: i18n.t('mock.inventoryNot'), value: 'understock' },
	{ label: i18n.t('mock.SaleNot'), value: 'sale' },
	{ label: i18n.t('mock.AbnormalNot'), value: 'tException' },
	{ label: i18n.t('mock.failureNot'), value: 'mFault' }
]
let emailTypeList = [
	{ label: i18n.t('mock.onlineStatus'), value: 'online' },
	{ label: i18n.t('mock.outStock'), value: 'understock' },
	{ label: i18n.t('mock.saleNotices'), value: 'sale' },
	{ label: i18n.t('mock.AbnormalNot'), value: 'tException' },
	{ label: i18n.t('mock.failureNot'), value: 'mFault' },
	{ label: i18n.t('mock.abnormality'), value: 'unitException' }
]
// 变化分类
let typeChangeList = [
	{ label: i18n.t('machine.custom.unknown'), value: 1 },
	{ label: i18n.t('mock.exhibit'), value: 2 },
	{ label: i18n.t('mock.unload'), value: 3 },
	{ label: i18n.t('mock.surplus'), value: 4 },
	{ label: i18n.t('mock.loss'), value: 5 },
	{ label: i18n.t('mock.Backend'), value: 6 },
	{ label: i18n.t('mock.stock'), value: 7 },
	{ label: i18n.t('mock.BAD'), value: 8 },
	{ label: i18n.t('mock.recoveryBAD'), value: 9 },
	{ label: i18n.t('mock.TerminalBAD'), value: 10 },
	{ label: i18n.t('mock.recoveryTerminal'), value: 11 }
]
// 角色等级
let name = [
	i18n.t('mock.backend'),
	i18n.t('mock.Firstlevel'),
	i18n.t('mock.Secondary'),
	i18n.t('mock.Thirdlevel'),
	i18n.t('mock.levelFour'),
]

// 素材类型
let ivideo = [
	{ label: i18n.t('mock.general'), value: 0 },
	{ label: i18n.t('public.picture'), value: 1 },
	{ label: i18n.t('source.video'), value: 2 },
	{ label: i18n.t('source.audio'), value: 3 },
]

// 状态
let status = [
	{ label: i18n.t('machine.custom.unknown'), value: 0 },
	{ label: i18n.t('public.enable'), value: 1 },
	{ label: i18n.t('public.disable'), value: 2 },
]

// 订单类型
let order_type = [
	{ label: i18n.t('machine.custom.unknown'), value: 0 },
	{ label: i18n.t('mock.regularOrder'), value: 1 },
	{ label: i18n.t('mock.cuponOrder'), value: 2 },
	{ label: i18n.t('mock.codeOrder'), value: 3 },
	{ label: i18n.t('mock.BlindBox'), value: 4 },
	{ label: i18n.t('mock.Fulldiscount'), value: 5 }
]
let order_pay_child = [
	{
		value: '1V', label: i18n.t('order.goods.onlinePay'), children: [
			{ value: '5', label: i18n.t('order.goods.Member') },
			{ value: '6', label: i18n.t('order.goods.LichengPay') },
			{ value: '7', label: i18n.t('order.goods.RobotPay') }
		]
	},
	{
		value: '2V', label: i18n.t('order.goods.offlinePay'), children: [
			{ value: '1', label: i18n.t('order.goods.WeChatPay') },
			{ value: '2', label: i18n.t('order.goods.alipayPay') },
			{ value: '4', label: i18n.t('order.goods.JD') },
			{ value: '8',label: i18n.t('order.goods.Cogolink') }
		]
	}
]

// 支付类型
let order_pay = [
	{ label: i18n.t('order.goods.free'), value: 0 },
	{ label: i18n.t('order.goods.WeChatPay'), value: 1 },
	{ label: i18n.t('order.goods.alipayPay'), value: 2 },
	// { label:'通联支付', value: 3 },
	{ label: i18n.t('order.goods.JD'), value: 4 },
	{ label: i18n.t('order.goods.Member'), value: 5 },
	{ label: i18n.t('order.goods.LichengPay'), value: 6 },
	{ label: i18n.t('order.goods.RobotPay'), value: 7 },
	{ label: i18n.t('order.goods.Cogolink'), value: 8 }
]
// 支付类型
let order_payGoods = [
	{ label: i18n.t('order.goods.free'), value: 0 },
	{ label: i18n.t('order.goods.WeChatPay'), value: 1 },
	{ label: i18n.t('order.goods.alipayPay'), value: 2 },
	// { label:'通联支付', value: 3 },
	{ label: i18n.t('order.goods.JD'), value: 4 }
]

// 支付方式
let pay_method = [
	{ label: i18n.t('machine.custom.unknown'), value: 0 },
	// { label: i18n.t('order.goods.free'), value: 1 },
	// { label: i18n.t('order.goods.payCode'), value: 11 },
	// { label: i18n.t('order.goods.JSAPIpay'), value: 12 },
	// { label: i18n.t('order.goods.programPay'), value: 13 },
	// { label: i18n.t('order.goods.NativePay'), value: 14 },
	// { label: i18n.t('order.goods.scanPay'), value: 15 },
	// { label: i18n.t('order.goods.websitePay'), value: 21 },
	// { label: i18n.t('order.goods.facePay'), value: 22 },
	// { label: i18n.t('order.goods.facescanPay'), value: 23 },
	{ label: i18n.t('order.goods.ScancodePay'), value: 1 },
	{ label: i18n.t('order.goods.AntiPay'), value: 2 },
	{ label: i18n.t('order.goods.POS'), value: 3 }
	// { label: i18n.t('order.goods.CardPay'), value: 42 },
]

// 广告投放位置
let adv_postion = [
	{ label: i18n.t('mock.terminal'), value: 1 },
	{ label: i18n.t('mock.GiftAnimation'), value: 2 },
	{ label: i18n.t('mock.shipmentAnim'), value: 3 },
	{ label: i18n.t('mock.pickupAnim'), value: 4 },
	{ label: i18n.t('mock.MachineAnim'), value: 5 },
	{ label: i18n.t('mock.MachinepickupAnim'), value: 6 },
	{ label: i18n.t('mock.resultPpage'), value: 8 },
	{ label: i18n.t('mock.SmallAnim'), value: 9 },
	{ label: i18n.t('mock.homepage'), value: 10 },
	{ label: i18n.t('mock.payment'), value: 11 },
	{ label: i18n.t('mock.giftSound'), value: 12 },
	{ label: i18n.t('mock.pickupPrompt'), value: 13 },
	{ label: i18n.t('mock.NextPickup'), value: 14 },
	{ label: i18n.t('mock.completetran'), value: 15 },
	{ label: i18n.t('mock.Reminder'), value: 16 },
	{ label: i18n.t('mock.Remind'), value: 17 },
	{ label: i18n.t('mock.surprise'), value: 18 },
	{ label: i18n.t('mock.payAlipay'), value: 19 },
	{ label: i18n.t('mock.UnionPay'), value: 20 },
	{ label: i18n.t('mock.cardPay'), value: 21 },
	{ label: i18n.t('mock.WeChatPay'), value: 22 },
	{ label: i18n.t('mock.JDPay'), value: 23 },
	{ label: i18n.t('mock.HomeGreet'), value: 24 },
	{ label: i18n.t('mock.customers'), value: 25 },
	{ label: i18n.t('mock.POPPay'), value: 26 },
	{ label: i18n.t('mock.resultPpagecode'), value: 27 },
]

// 系统角色等级
let getPlevel = (e) => {
	return name[e * 1 - 1]
}


// 系统订单类型
// k: 1返回列表信息
let getPorder = (e, k) => {
	if (k == 1) {
		return order_type
	}
	let tpye = order_type[0].label
	for (let item of order_type) {
		if (item.value == e) {
			tpye = item.label
		}
	}
	return tpye
}
let payGoods = (e, k) => {
	if (k == 1) {
		return order_type
	}
	let tpye = order_type[0].label
	for (let item of order_payGoods) {
		if (item.value == e) {
			tpye = item.label
		}
	}
	return tpye
}

// 系统订单支付类型
// k: 1返回列表信息
let getPpay = (e, k) => {
	if (k == 1) {
		return order_pay
	}
	let pay = order_pay[0].label
	for (let item of order_pay) {
		if (item.value == e) {
			pay = item.label
		}
	}
	return pay
}

// 系统支付方式
// k：1返回列表信息
let getpaymeod = (e, k) => {
	if (k == 1) {
		return pay_method
	}
	let paymetod = pay_method[0].label
	for (let item of pay_method) {
		if (item.value == e) {
			paymetod = item.label
		}
	}
	return paymetod
}

// 日期 e：时间戳，k：1年月日，2时分秒，3年月日时分秒
let gettime = (e, k) => {
	if (e == undefined || e == null || e == '') {
		return '--'
	}
	let length = e.toString().length
	let num = 13 - length
	for (let i = 0; i < num; i++) {
		e = (e += '0') * 1
	}
	let date = new Date(e);
	let YMD = {
		year: date.getFullYear(),
		month: ('0' + (date.getMonth() + 1)).slice(-2),
		day: ('0' + date.getDate()).slice(-2),
		hours: ('0' + date.getHours()).slice(-2),
		minutes: ('0' + date.getMinutes()).slice(-2),
		seconds: ('0' + date.getSeconds()).slice(-2)
	}
	let time = ''
	switch (k) {
		case 1:
			time = YMD.year + '-' + YMD.month + '-' + YMD.day
			break;
		case 2:
			time = YMD.hours + ':' + YMD.minutes + ':' + YMD.seconds
			break;
		case 3:
			time = YMD.year + '-' + YMD.month + '-' + YMD.day + ' ' + YMD.hours + ':' + YMD.minutes + ':' + YMD.seconds
			break;
	}
	return time
}

// 秒数转时分秒
let gettohms = (seconds) => {
	var hours = Math.floor(seconds / 3600); // 计算小时部分
	seconds %= 3600; // 取余得到不足1小时的秒数

	var minutes = Math.floor(seconds / 60); // 计算分钟部分
	seconds %= 60; // 取余得到不足1分钟的秒数

	if (hours <= 9) {
		hours = '0' + hours
	}

	if (minutes <= 9) {
		minutes = '0' + minutes
	}

	if (seconds <= 9) {
		seconds = '0' + seconds
	}

	let hms = hours + ':' + minutes + ':' + seconds

	return hms
}

// 素材类型 e:值，k:1返回类型，2返回数组
let materialtype = (e, k) => {
	if (k == 2) {
		return ivideo
	}
	return ivideo[e].label
}

// 状态类型 e:值，k:1返回类型，2返回数组
let statustype = (e, k) => {
	if (k == 2) {
		let arr = []
		for (let i = 1; i < status.length; i++) {
			arr.push(status[i])
		}
		return arr
	}

	return status[e].label
}

// 保留小数点后两位
let getmoney = (e) => {
	let num = e * 1
	return num.toFixed(2)
}

// 计算文件大小/流量
// k:1计算文件、2计算流量
let measure = (e, l) => {
	if (e === 0 || e === null || e === '' || e === undefined) return '0KB'
	const k = 1024 // or 1024
	let sizes = ['K', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']
	let num = 1
	const i = Math.floor(Math.log(e) / Math.log(k))
	if (l == 2) {
		sizes = ['KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']
		num = 3
	} else {
		const filesize = (e / Math.pow(k, i))
		if (filesize >= 10) {
			num = 2
		}
		if (filesize >= 100) {
			num = 3
		}
	}
	return (e / Math.pow(k, i)).toPrecision(num) + '' + sizes[i]
}

// 广告投放位置
// e: 1 返回数组，2 返回类型
// l: 类型ID
let getadvpos = (e, l) => {
	let name = '未知'
	if (e == 1) {
		return adv_postion
	}

	if (e == 2) {
		for (let item of adv_postion) {
			if (item.value == l) {
				name = item.label
			}
		}
	}
	return name
}
// 设置返回列表数据状态
let setStatus = (e) => {
	if (e === 1) {
		return e = i18n.t('public.enable')
	}
	if (e === 2) {
		return e = i18n.t('public.disable')
	}
}

export default {
	getPlevel,
	getPorder,
	payGoods,
	getPpay,
	getpaymeod,
	gettime,
	materialtype,
	statustype,
	getmoney,
	measure,
	gettohms,
	getadvpos,
	setStatus,
	positionList,
	typeChangeList,
	emailTypeList,
	gType_list,
	noticeList,
	order_pay_child
}